// Created from GenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.Reflection;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.Generated.AbstractMessage;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using TX = System.String;
using FT = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class EHC_E12 : AbstractMessage
    {
		/// Constructor
		public EHC_E12() : base()
        {
			if (MSH != null) {
                MSH.MessageType = new MSG() { MessageCode = "EHC", TriggerEvent = "E12" };
			}
        }

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("SFT",2)]
  	    [HL7Field(HL7Version.v26, 2, HL7Repeat.True, HL7Required.False,"SFT")]
  	    [HL7Field(HL7Version.v27, 2, HL7Repeat.True, HL7Required.False,"SFT")]
	    public SFT[] SFT {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("UAC",3)]
  	    [HL7Field(HL7Version.v26, 3, HL7Repeat.True, HL7Required.False,"UAC")]
  	    [HL7Field(HL7Version.v27, 3, HL7Repeat.True, HL7Required.False,"UAC")]
	    public UAC[] UAC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("RFI",4)]
  	    [HL7Field(HL7Version.v26, 4, HL7Repeat.False, HL7Required.True,"RFI")]
  	    [HL7Field(HL7Version.v27, 4, HL7Repeat.False, HL7Required.True,"RFI")]
	    public RFI RFI {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("CTD",5)]
  	    [HL7Field(HL7Version.v26, 5, HL7Repeat.True, HL7Required.False,"CTD")]
  	    [HL7Field(HL7Version.v27, 5, HL7Repeat.True, HL7Required.False,"CTD")]
	    public CTD[] CTD {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("IVC",6)]
  	    [HL7Field(HL7Version.v26, 6, HL7Repeat.False, HL7Required.True,"IVC")]
  	    [HL7Field(HL7Version.v27, 6, HL7Repeat.False, HL7Required.True,"IVC")]
	    public IVC IVC {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PSS",7)]
  	    [HL7Field(HL7Version.v26, 7, HL7Repeat.False, HL7Required.True,"PSS")]
  	    [HL7Field(HL7Version.v27, 7, HL7Repeat.False, HL7Required.True,"PSS")]
	    public PSS PSS {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PSG",8)]
  	    [HL7Field(HL7Version.v26, 8, HL7Repeat.False, HL7Required.True,"PSG")]
  	    [HL7Field(HL7Version.v27, 8, HL7Repeat.False, HL7Required.True,"PSG")]
	    public PSG PSG {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PID",9)]
  	    [HL7Field(HL7Version.v26, 9, HL7Repeat.False, HL7Required.False,"PID")]
  	    [HL7Field(HL7Version.v27, 9, HL7Repeat.False, HL7Required.False,"PID")]
	    public PID PID {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("PSL",10)]
  	    [HL7Field(HL7Version.v26, 10, HL7Repeat.True, HL7Required.False,"PSL")]
  	    [HL7Field(HL7Version.v27, 10, HL7Repeat.True, HL7Required.False,"PSL")]
	    public PSL[] PSL {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
        [PropertyClassification("REQUEST",11)]
  	    [HL7Field(HL7Version.v26, 11, HL7Repeat.True, HL7Required.True,"REQUEST_EHC_E12")]
  	    [HL7Field(HL7Version.v27, 11, HL7Repeat.True, HL7Required.True,"REQUEST_EHC_E12")]
	    public REQUEST_EHC_E12[] REQUEST {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override Stack<string> ConsumeTextSegments(Stack<string> availableData, HL7ParserOptions options) {

				if (HL7Version.v26 == options.Version) {
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequiredArray<UAC>(availableData, options, "UAC");
		 RFI = PopSegmentParseAndCheckRequired<RFI>(availableData, options, "RFI");
		 CTD = PopSegmentParseAndCheckRequiredArray<CTD>(availableData, options, "CTD");
		 IVC = PopSegmentParseAndCheckRequired<IVC>(availableData, options, "IVC");
		 PSS = PopSegmentParseAndCheckRequired<PSS>(availableData, options, "PSS");
		 PSG = PopSegmentParseAndCheckRequired<PSG>(availableData, options, "PSG");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PSL = PopSegmentParseAndCheckRequiredArray<PSL>(availableData, options, "PSL");
		 REQUEST = ProcessGroupArray<REQUEST_EHC_E12>(availableData, options, "REQUEST");
		}
		if (HL7Version.v27 == options.Version) {
		 SFT = PopSegmentParseAndCheckRequiredArray<SFT>(availableData, options, "SFT");
		 UAC = PopSegmentParseAndCheckRequiredArray<UAC>(availableData, options, "UAC");
		 RFI = PopSegmentParseAndCheckRequired<RFI>(availableData, options, "RFI");
		 CTD = PopSegmentParseAndCheckRequiredArray<CTD>(availableData, options, "CTD");
		 IVC = PopSegmentParseAndCheckRequired<IVC>(availableData, options, "IVC");
		 PSS = PopSegmentParseAndCheckRequired<PSS>(availableData, options, "PSS");
		 PSG = PopSegmentParseAndCheckRequired<PSG>(availableData, options, "PSG");
		 PID = PopSegmentParseAndCheckRequired<PID>(availableData, options, "PID");
		 PSL = PopSegmentParseAndCheckRequiredArray<PSL>(availableData, options, "PSL");
		 REQUEST = ProcessGroupArray<REQUEST_EHC_E12>(availableData, options, "REQUEST");
		}
			if (availableData != null && availableData.Count > 0) {
				ConsumeZSegmentsFromText(availableData, options);
			}
            return availableData;
        
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "EHC_E12";
			}
        }

        static EHC_E12() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(EHC_E12));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
			if (MSH != null) {
				segmentData.Add(MSH.GetER7(options));
			}
			if (SFT != null && SFT.Length > 0) {
				for (int i = 0; i < SFT.Length; i++) {
					segmentData.Add(SFT[i].GetER7(options));
				}
			}
			if (UAC != null && UAC.Length > 0) {
				for (int i = 0; i < UAC.Length; i++) {
					segmentData.Add(UAC[i].GetER7(options));
				}
			}
			if (RFI != null) {
				segmentData.Add(RFI.GetER7(options));
			}
			if (CTD != null && CTD.Length > 0) {
				for (int i = 0; i < CTD.Length; i++) {
					segmentData.Add(CTD[i].GetER7(options));
				}
			}
			if (IVC != null) {
				segmentData.Add(IVC.GetER7(options));
			}
			if (PSS != null) {
				segmentData.Add(PSS.GetER7(options));
			}
			if (PSG != null) {
				segmentData.Add(PSG.GetER7(options));
			}
			if (PID != null) {
				segmentData.Add(PID.GetER7(options));
			}
			if (PSL != null && PSL.Length > 0) {
				for (int i = 0; i < PSL.Length; i++) {
					segmentData.Add(PSL[i].GetER7(options));
				}
			}
			if (REQUEST != null && REQUEST.Length > 0) {
				for (int i = 0; i < REQUEST.Length; i++) {
					segmentData.Add(REQUEST[i].GetER7(options));
				}
			}
           segmentData.AddRange(GetZSegmentsER7(options));
		   return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }


    }
}

